package org.client.iot.domain;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import com.alibaba.fastjson2.JSONObject;

public class WifiInfo implements Parcelable {
    private String ssid;
    private String bssid;
    private String capabilities;
    private Integer frequency;
    private String frequencyTag;
    private Integer level;
    private String pwd;

    public WifiInfo(String ssid, String bssid, String capabilities, Integer frequency, String frequencyTag, Integer level, String pwd) {
        this.ssid = ssid;
        this.bssid = bssid;
        this.capabilities = capabilities;
        this.frequency = frequency;
        this.frequencyTag = frequencyTag;
        this.level = level;
        this.pwd = pwd;
    }


    protected WifiInfo(Parcel in) {
        ssid = in.readString();
        bssid = in.readString();
        capabilities = in.readString();
        if (in.readByte() == 0) {
            frequency = null;
        } else {
            frequency = in.readInt();
        }
        frequencyTag = in.readString();
        if (in.readByte() == 0) {
            level = null;
        } else {
            level = in.readInt();
        }
        pwd = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(ssid);
        dest.writeString(bssid);
        dest.writeString(capabilities);
        if (frequency == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(frequency);
        }
        dest.writeString(frequencyTag);
        if (level == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(level);
        }
        dest.writeString(pwd);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<WifiInfo> CREATOR = new Creator<WifiInfo>() {
        @Override
        public WifiInfo createFromParcel(Parcel in) {
            return new WifiInfo(in);
        }

        @Override
        public WifiInfo[] newArray(int size) {
            return new WifiInfo[size];
        }
    };

    public String getSsid() {
        return ssid;
    }

    public void setSsid(String ssid) {
        this.ssid = ssid;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getBssid() {
        return bssid;
    }

    public void setBssid(String bssid) {
        this.bssid = bssid;
    }

    public String getCapabilities() {
        return capabilities;
    }

    public void setCapabilities(String capabilities) {
        this.capabilities = capabilities;
    }

    public Integer getFrequency() {
        return frequency;
    }

    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }

    public String getFrequencyTag() {
        return frequencyTag;
    }

    public void setFrequencyTag(String frequencyTag) {
        this.frequencyTag = frequencyTag;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }



}
